/*
** my_getnbr.c for my_getnbr in /u/all/nadali_t/rendu/lib/my/src
** 
** Made by thomas nadalie
** Login   <nadali_t@epitech.net>
** 
** Started on  Mon Oct 24 19:21:14 2011 thomas nadalie
** Last update Mon Feb  6 15:44:34 2012 thomas nadalie
*/

void	my_putchar(char c)
{
  write(1, &c, 1);
}

void	my_put_nbr(int nb)
{
  if (nb < 0)
    {
      my_putchar('-');
      nb = nb * -1;
    }
  if (nb > 9)
    my_put_nbr(nb/10);

  my_putchar((nb % 10) + 48);
}

int             my_getnbr(char *str)
{
  int           result;
  int           puiss;

  result = 0;
  puiss = 1;
  while (('-' == (*str)) || ((*str) == '+'))
    {
      if (*str == '-')
        puiss = puiss * -1;
      str++;
    }
  while ((*str >= '0') && (*str <= '9'))
    {
      result = (result * 10) + ((*str) - '0');
      str++;
    }
  return (result * puiss);
}

int	main()
{
  char			*i;


  i = "x";
  my_getnbr(i);
  my_put_nbr(i);
  return (0);
}
